﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zocono.WCS.Domain.PlcBytesObject
{
    /// <summary>
    /// 平面设备电池条码扫码Plc动作报文
    /// </summary>
    public class PlanarBatteryScanPlcActionBO : BytesObjectBase
    {
        /// <summary>
        /// 任务号
        /// </summary>
        public int TaskCode { get; set; }
        /// <summary>
        /// 目标位置编号
        /// </summary>
        public int ToEquipmentCode { get; set; }
        /// <summary>
        /// 托盘条码
        /// </summary>
        public string PalletBarcode { get; set; }

        /// <summary>
        /// 请求读取电池条码握手   
        /// </summary>
        public short ActionType { get; set; }
        ///// <summary>
        ///// 空托满托
        ///// </summary>
        //public short IsFull { get; set; }

        public byte PalletType { get; set; }
        public byte AlrmCode { get; set; }

        /// <summary>
        /// 预留
        /// </summary>
        public byte Reserve { get; set; }
        public byte Reserve2 { get; set; }
        public byte Reserve3 { get; set; }
        public byte Reserve4 { get; set; }
        /// <summary>
        /// 托盘条码2
        /// </summary>
        public string PalletBarcode2 { get; set; }

        #region 电池
        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode1 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode2 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode3 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode4 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode5 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode6 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode7 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode8 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode9 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode10 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode11 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode12 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode13 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode14 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode15 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode16 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode17 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode18 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode19 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode20 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode21 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode22 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode23 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode24 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode25 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode26 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode27 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode28 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode29 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode30 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode31 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode32 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode33 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode34 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode35 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode36 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode37 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode38 { get; set; }
        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode39 { get; set; }

        /// <summary>
        /// 1#电池条码
        /// </summary>
        public string BatteryCode40 { get; set; }

        #endregion

        public override void Serialize(long plcConnectionID, long plcReadDbID, int bytesIndex, int bytesLength, int objectIndex, int objectLength, string objectType, string ScEquipmentCode, byte[] bytes)
        {
            PlcConnectionID = plcConnectionID;
            PlcReadDbID = plcReadDbID;
            BytesIndex = bytesIndex;
            BytesLength = bytesLength;
            ObjectIndex = objectIndex;
            ObjectLength = objectLength;
            ObjectType = objectType;


            //EquipmentCode = HelperByte.GetDIntAt(bytes, 0).ToString();
            //TaskCode = HelperByte.GetDIntAt(bytes, 4);
            //ToEquipmentCode = HelperByte.GetDIntAt(bytes, 8);
            //int length1 = HelperByte.GetSIntAt(bytes, 17);
            //PalletBarcode = HelperByte.GetCharsAt(bytes, 18, length1);
            //ActionType = HelperByte.GetIntAt(bytes, 32);
            //PalletType = HelperByte.GetByteAt(bytes, 34);
            //AlrmCode = HelperByte.GetByteAt(bytes, 35);
            //Reserve = HelperByte.GetByteAt(bytes, 36);//视觉检测则是显示电池数量
            //Reserve2 = HelperByte.GetByteAt(bytes, 37);
            //Reserve3 = HelperByte.GetByteAt(bytes, 38);
            //Reserve4 = HelperByte.GetByteAt(bytes, 39);


            //EquipmentCode = HelperByte.GetCharsAt(bytes, 2, length);
            //TaskCode = HelperByte.GetDIntAt(bytes, 8);
            //length = HelperByte.GetSIntAt(bytes, 13);
            //ToEquipmentCode = HelperByte.GetCharsAt(bytes, 14, length);
            //length = HelperByte.GetSIntAt(bytes, 21);
            //PalletBarcode = HelperByte.GetCharsAt(bytes, 22, length);
            //IsFull = HelperByte.GetIntAt(bytes, 40);
            //ActionType = HelperByte.GetIntAt(bytes, 42);
            //Reserve = HelperByte.GetIntAt(bytes, 44);
            //Reserve2 = HelperByte.GetIntAt(bytes, 46);

            int length = HelperByte.GetSIntAt(bytes, 1);
            BatteryCode1 = HelperByte.GetCharsAt(bytes, 2, length);

            length = HelperByte.GetSIntAt(bytes, 33);
            BatteryCode2 = HelperByte.GetCharsAt(bytes, 34, length);

            length = HelperByte.GetSIntAt(bytes, 65);
            BatteryCode3 = HelperByte.GetCharsAt(bytes, 66, length);

            length = HelperByte.GetSIntAt(bytes, 97);
            BatteryCode4 = HelperByte.GetCharsAt(bytes, 98, length);

            length = HelperByte.GetSIntAt(bytes, 129);
            BatteryCode5 = HelperByte.GetCharsAt(bytes, 130, length);

            length = HelperByte.GetSIntAt(bytes, 161);
            BatteryCode6 = HelperByte.GetCharsAt(bytes,162, length);

            length = HelperByte.GetSIntAt(bytes, 193);
            BatteryCode7 = HelperByte.GetCharsAt(bytes, 194, length);

            length = HelperByte.GetSIntAt(bytes, 225);
            BatteryCode8 = HelperByte.GetCharsAt(bytes, 226, length);

            length = HelperByte.GetSIntAt(bytes, 257);
            BatteryCode9 = HelperByte.GetCharsAt(bytes, 258, length);

            length = HelperByte.GetSIntAt(bytes, 289);
            BatteryCode10 = HelperByte.GetCharsAt(bytes, 290, length);

            length = HelperByte.GetSIntAt(bytes, 321);
            BatteryCode11 = HelperByte.GetCharsAt(bytes,322, length);

            length = HelperByte.GetSIntAt(bytes, 353);
            BatteryCode12 = HelperByte.GetCharsAt(bytes, 354, length);

            length = HelperByte.GetSIntAt(bytes, 385);
            BatteryCode13 = HelperByte.GetCharsAt(bytes, 386, length);

            length = HelperByte.GetSIntAt(bytes, 417);
            BatteryCode14 = HelperByte.GetCharsAt(bytes, 418, length);

            length = HelperByte.GetSIntAt(bytes, 449);
            BatteryCode15 = HelperByte.GetCharsAt(bytes, 450, length);

            length = HelperByte.GetSIntAt(bytes, 481);
            BatteryCode16 = HelperByte.GetCharsAt(bytes, 482, length);

            length = HelperByte.GetSIntAt(bytes, 513);
            BatteryCode17 = HelperByte.GetCharsAt(bytes, 514, length);

            length = HelperByte.GetSIntAt(bytes, 545);
            BatteryCode18 = HelperByte.GetCharsAt(bytes, 546, length);

            length = HelperByte.GetSIntAt(bytes, 577);
            BatteryCode19 = HelperByte.GetCharsAt(bytes, 578, length);

            length = HelperByte.GetSIntAt(bytes, 609);
            BatteryCode20 = HelperByte.GetCharsAt(bytes, 610, length);

            length = HelperByte.GetSIntAt(bytes, 641);
            BatteryCode21 = HelperByte.GetCharsAt(bytes, 642, length);

            length = HelperByte.GetSIntAt(bytes, 673);
            BatteryCode22 = HelperByte.GetCharsAt(bytes, 674, length);

            length = HelperByte.GetSIntAt(bytes, 705);
            BatteryCode23 = HelperByte.GetCharsAt(bytes, 706, length);

            length = HelperByte.GetSIntAt(bytes, 737);
            BatteryCode24 = HelperByte.GetCharsAt(bytes, 738, length);

            length = HelperByte.GetSIntAt(bytes, 769);
            BatteryCode25 = HelperByte.GetCharsAt(bytes, 770, length);

            length = HelperByte.GetSIntAt(bytes, 801);
            BatteryCode26 = HelperByte.GetCharsAt(bytes, 802, length);

            length = HelperByte.GetSIntAt(bytes, 833);
            BatteryCode27 = HelperByte.GetCharsAt(bytes, 834, length);

            length = HelperByte.GetSIntAt(bytes, 865);
            BatteryCode28 = HelperByte.GetCharsAt(bytes, 866, length);

            length = HelperByte.GetSIntAt(bytes, 897);
            BatteryCode29 = HelperByte.GetCharsAt(bytes, 898, length);

            length = HelperByte.GetSIntAt(bytes, 929);
            BatteryCode30 = HelperByte.GetCharsAt(bytes, 930, length);

            length = HelperByte.GetSIntAt(bytes, 961);
            BatteryCode31 = HelperByte.GetCharsAt(bytes, 962, length);

            length = HelperByte.GetSIntAt(bytes, 993);
            BatteryCode32 = HelperByte.GetCharsAt(bytes, 994, length);

            length = HelperByte.GetSIntAt(bytes, 1025);
            BatteryCode33 = HelperByte.GetCharsAt(bytes, 1026, length);

            length = HelperByte.GetSIntAt(bytes, 1057);
            BatteryCode34 = HelperByte.GetCharsAt(bytes, 1058, length);

            length = HelperByte.GetSIntAt(bytes, 1089);
            BatteryCode35 = HelperByte.GetCharsAt(bytes, 1090, length);

            length = HelperByte.GetSIntAt(bytes, 1121);
            BatteryCode36 = HelperByte.GetCharsAt(bytes, 1122, length);

            length = HelperByte.GetSIntAt(bytes, 1153);
            BatteryCode37 = HelperByte.GetCharsAt(bytes, 1154, length);

            length = HelperByte.GetSIntAt(bytes, 1185);
            BatteryCode38 = HelperByte.GetCharsAt(bytes, 1186, length);

            length = HelperByte.GetSIntAt(bytes, 1217);
            BatteryCode39 = HelperByte.GetCharsAt(bytes, 1218, length);

            length = HelperByte.GetSIntAt(bytes, 1249);
            BatteryCode40 = HelperByte.GetCharsAt(bytes, 1250, length);
        }

    }
}
